/* Copyright (c) [2019年5月1日] [吴超]
[MBT_Studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
 */
#include "stdafx.h"
#include "list/list物体插座.h"
#include "通用插座.h"
#include "C_物体插座.h"
//#include "系统/多线程.h"
#include "节点/编译声明代码.h"

using namespace std;


/*void f_socket_resize网格插座数据(std::vector<S_网格插座数据>& data, uint32 num) {
	if (data.size() > num) {
		for (uint32 i = num; i < data.size(); ++i) {
			f_surface_释放网格对象(data[i].m_GPU网格);
		}
	}

	data.resize(num);
}*/


/*PyObject* f_构建Py网格数据(const S_网格插座数据& m_Value) {
	
	PyObject* mesh = PyTuple_New(11);

	if (m_Value.m_顶点) {
		uint32 num = m_Value.m_顶点->size();

		auto* v = m_Value.m_顶点->data();
		PyObject* vert = f_vec3转PyObject(v, num);
		PyTuple_SetItem(mesh, 0, vert);
	} else {
		PyTuple_SetItem(mesh, 0, PyList_New(0));
	}

	
	if (m_Value.m_法线) {
		uint32 num = m_Value.m_法线->size();

		auto* v = m_Value.m_法线->data();
		PyObject* normal = f_vec3转PyObject(v, num);
		PyTuple_SetItem(mesh, 1, normal);
	} else {
		PyTuple_SetItem(mesh, 1, PyList_New(0));
	}



	if (m_Value.m_UV1) {
		PyObject* uv = f_blUV构建PyObject数据(m_Value.m_UV1, m_Value.m_索引);
		//PyObject* uv = f_ArrayVec2转PyObject(*m_Value.m_UV1);
		PyTuple_SetItem(mesh, 2, uv);
	}
	else {
		PyTuple_SetItem(mesh, 2, PyList_New(0));
	}



	if (m_Value.m_UV2) {
		PyObject* uv = f_blUV构建PyObject数据(m_Value.m_UV2, m_Value.m_索引);
		//PyObject* uv = f_ArrayVec2转PyObject(*m_Value.m_UV2);
		PyTuple_SetItem(mesh, 3, uv);
	}
	else {
		PyTuple_SetItem(mesh, 3, PyList_New(0));
	}
	



	if (m_Value.m_UV) {
		PyObject* uv = f_blUV构建PyObject数据(m_Value.m_UV);
		PyTuple_SetItem(mesh, 4, uv);
	}
	else {
		PyTuple_SetItem(mesh, 4, PyList_New(0));
	}






	if (m_Value.m_面法线) {
		uint32 num = m_Value.m_面法线->size();

		auto* v = m_Value.m_面法线->data();
		PyObject* normal = f_vec3转PyObject(v, num);
		PyTuple_SetItem(mesh, 5, normal);
	}
	else {
		PyTuple_SetItem(mesh, 5, PyList_New(0));
	}



	
	if (m_Value.m_面中心) {
		uint32 num = m_Value.m_面中心->size();

		auto* v = m_Value.m_面中心->data();
		PyObject* fasec = f_vec3转PyObject(v, num);
		PyTuple_SetItem(mesh, 6, fasec);
	}
	else {
		PyTuple_SetItem(mesh, 6, PyList_New(0));
	}




	if (m_Value.m_边索引) {
		PyObject* edge = f_ArrayIVec2转PyObject(*m_Value.m_边索引);
		PyTuple_SetItem(mesh, 7, edge);
	}
	else {
		PyTuple_SetItem(mesh, 7, PyList_New(0));
	}

	


	if (m_Value.m_索引) {
		PyObject* fasec = f_多边形索引转PyObject(m_Value.m_索引);
		PyTuple_SetItem(mesh, 8, fasec);
	} else {
		PyTuple_SetItem(mesh, 8, PyList_New(0));
	}




	if (m_Value.m_材质ID) {
		PyObject* fasec = f_ArrayUint32转PyObject(*m_Value.m_材质ID);
		PyTuple_SetItem(mesh, 9, fasec);
	} else {
		PyTuple_SetItem(mesh, 9, PyList_New(0));
	}





	if (m_Value.m_材质槽) {
		uint32 槽数量 = m_Value.m_材质槽->size();
		PyObject* 材质槽 = PyList_New(槽数量);

		auto* p材质槽 = m_Value.m_材质槽->data();
		for (uint32 i = 0; i < 槽数量; ++i) {
			PyList_SetItem(材质槽, i, p材质槽[i].m_bl材质);
		}
		//PyObject* 材质槽 = f_ArrayUint32转PyObject(*m_Value.m_材质ID);
		PyTuple_SetItem(mesh, 10, 材质槽);
	}
	else {
		PyTuple_SetItem(mesh, 10, PyList_New(0));
	}

	return mesh;
}*/

/*bool f_从Py数据构建网格(S_网格插座数据* mesh, PyObject* item) {
	PyObject* 顶点		= PyList_GetItem(item, 1);
	PyObject* 法线		= PyList_GetItem(item, 2);
	PyObject* UV		= PyList_GetItem(item, 3);
	PyObject* UV坐标	= PyList_GetItem(item, 4);

	PyObject* 索引		= PyList_GetItem(item, 5);
	PyObject* 面法线	= PyList_GetItem(item, 6);
	PyObject* 面中心	= PyList_GetItem(item, 7);

	PyObject* 边		= PyList_GetItem(item, 8);
	PyObject* 环		= PyList_GetItem(item, 9);
	PyObject* 多边形	= PyList_GetItem(item, 10);

	PyObject* 面材质ID	= PyList_GetItem(item, 11);
	PyObject* 材质槽	= PyList_GetItem(item, 12);


	f_创建独立网格插座数量(mesh);





	//C_Vector1D_Vec3插座* vs = DEF_转换为arrayVec3插座(f_get输出插座(1));
	f_PyObj_to_vec3s(顶点, *mesh->m_顶点);
	//C_Vector1D_Vec3插座* ns = DEF_转换为arrayVec3插座(f_get输出插座(2));
	f_PyObj_to_vec3s(法线, *mesh->m_法线);
	//C_Vector1D_Vec3插座* uv1 = DEF_转换为arrayVec3插座(f_get输出插座(2));
	f_PyObj_to_vec2s(UV, *mesh->m_UV1);


	uint32 uvNum = PyList_Size(UV坐标);
	mesh->m_UV->resize(uvNum);
	for (uint32 i = 0; i < uvNum; ++i) {
		PyObject* uvLayout = PyList_GetItem(UV坐标, i);
		f_PyObj_to_vec2s(uvLayout, (*(mesh->m_UV))[i]);
	}



	//C_面顶点索引插座* is = DEF_转换为面顶点索引插座(f_get输出插座("面索引"));
	f_PyObj_to_多边形索引(索引, *mesh->m_索引);
	//C_Vector1D_Vec3插座* fn = DEF_转换为arrayVec3插座(f_get输出插座("面法线"));
	f_PyObj_to_vec3s(面法线, *mesh->m_面法线);
	//C_Vector1D_Vec3插座* fc = DEF_转换为arrayVec3插座(f_get输出插座("面中心"));
	f_PyObj_to_vec3s(面中心, *mesh->m_面中心);

	f_PyObj_to_uint32_1D(面材质ID, *mesh->m_材质ID);




	uint32 材质槽数量 = PyList_Size(材质槽);
	mesh->m_材质槽->resize(材质槽数量);
	for (uint32 i = 0; i < 材质槽数量; ++i) {
		auto& 槽 = (*(mesh->m_材质槽))[i];
		PyObject* 槽项 = PyList_GetItem(材质槽, i);
		槽.m_bl材质 = PyTuple_GetItem(槽项, 0);
		槽.m_材质哈希 = PyLong_AsUnsignedLongLong(PyTuple_GetItem(槽项, 1));
	}



	return true;

}*/







C_物体插座::C_物体插座(std::wstring name) :C_插座基类(name, E_值类型::e_Type_Object) {
	m_Value = 0;
}

C_物体插座::~C_物体插座() {
	
}



void* C_物体插座::f_getData(uint8 当前插座连接线ID) {
	C_插座基类* socket = f_getLinkOutSocket(当前插座连接线ID);
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_Object) {
			return DEF_物体插座数据(socket, 当前插座连接线ID);

		}
		else if (socket->m_Type == E_值类型::e_Type_Object_1D) {
			auto* obs = DEF_物体插座_1D数据(socket, 0);
			if (obs->count) {
				m_Value = obs->ptr_userData[0];
			}
			else {
				m_Value = nullptr;
			}
		}
		else if (socket->m_Type == E_值类型::e_Type_Object_Array1D) {
			
		}
	}

	return m_Value;
}

void C_物体插座::f_setData(void* data, uint8 线程ID) {
	C_插座基类::f_setData(data);

	m_Value = (S_物体*)data;
	//m_ObjectName = *(string*)data;
}

std::string C_物体插座::f_构建变量代码(int32 loc) {
	C_插座基类* socket = f_getLinkOutSocket(0);
	std::string code;
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_Object) {
			m_Code = socket->f_getCode(loc);
			return "";
		}

		m_Code = m_pNode->f_getName() + f_getName() + "_new_val_to_object";

		std::string code = "S_物体* " + m_Code + " = nullptr;\n";
		switch (socket->m_Type) {
		case E_值类型::e_Type_Object_1D: {
			auto obCode = socket->f_getCode(loc);
			code += "if(" + obCode + "->count > 0)\n";
			code += m_Code + " = " + obCode + "->ptr_userData[0];\n";
			break;
		}
		default:
			return code;
		}
		
	}
	else {
		C_插座基类::f_构建变量代码(loc);
	}

	return code;
}

bool C_物体插座::f_接入插座是否匹配(E_值类型 type) {
	switch (type) {
	case E_值类型::e_Type_Object:
	case E_值类型::e_Type_ObjectData:
	case E_值类型::e_Type_Object_1D:
	case E_值类型::e_Type_Mesh:
	case E_值类型::e_插座Type_引用数据:
		return true;
	}
	return false;
}







C_骨架插座::C_骨架插座(std::wstring name) :C_插座基类(name, E_值类型::e_Type_骨架) {
	m_Value = nullptr;
}

C_骨架插座::~C_骨架插座() {
}

void* C_骨架插座::f_getData(uint8 当前插座连接线ID) {
	C_插座基类* socket = f_getLinkOutSocket(当前插座连接线ID);
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_骨架) {
			return socket->f_getData(当前插座连接线ID);
		}
		else if (socket->m_Type == E_值类型::e_Type_Object) {
			return DEF_物体插座数据(socket, 当前插座连接线ID);
		}
		else if (socket->m_Type == E_值类型::e_Type_Object_Array1D) {

		}
	}

	return m_Value;
}

void C_骨架插座::f_setData(void* data, uint8 当前插座连接线ID) {
	m_Value = (S_骨架*)data;
	m_有新数据 = true;

	auto linkSocket = f_get链接到的输入插座();
	for (auto& s : linkSocket) {
		s->m_有新数据 = true;
	}
}








C_骨骼插座::C_骨骼插座(std::wstring name) :C_插座基类(name, E_值类型::e_Type_骨骼) {
	m_Value = nullptr;
}

C_骨骼插座::~C_骨骼插座() {
}

void* C_骨骼插座::f_getData(uint8 当前插座连接线ID) {
	C_插座基类* socket = f_getLinkOutSocket(当前插座连接线ID);
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_骨骼) {
			return DEF_物体插座数据(socket, 当前插座连接线ID);
		}
		else if (socket->m_Type == E_值类型::e_Type_Object_Array1D) {

		}
	}

	return m_Value;
}

void C_骨骼插座::f_setData(void* data, uint8 当前插座连接线ID) {
	m_Value = (S_物体*)data;
	m_有新数据 = true;

	auto linkSocket = f_get链接到的输入插座();
	for (auto& s : linkSocket) {
		s->m_有新数据 = true;
	}
}








C_IK插座::C_IK插座(wstring name) :C_插座基类(name, E_值类型::e_Type_IK) {
	//m_Value = (S_骨骼IK*)malloc(sizeof(S_骨骼IK));
	m_Value = nullptr;
}

C_IK插座::~C_IK插座() {
	//free(m_Value);
}

void* C_IK插座::f_getData(uint8 当前插座连接线ID) {
	C_插座基类* socket = f_getLinkOutSocket(当前插座连接线ID);
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_IK) {
			return socket->f_getData(当前插座连接线ID);
		}
		else if (socket->m_Type == E_值类型::e_Type_骨骼) {
			return DEF_物体插座数据(socket, 当前插座连接线ID);
		}
		else if (socket->m_Type == E_值类型::e_Type_Object_Array1D) {

		}
	}

	return m_Value;
}

void C_IK插座::f_setData(void* data, uint8 当前插座连接线ID) {
	m_Value = (S_骨骼IK*)data;
}















C_网格插座::C_网格插座(std::wstring name) :C_插座基类(name, E_值类型::e_Type_Mesh) {
	//f_创建独立网格插座数量(&m_Value);
	m_Value = nullptr;
}

C_网格插座::~C_网格插座() {

}


void* C_网格插座::f_getData(uint8 当前插座连接线ID) {
	C_插座基类* socket = f_getLinkOutSocket(当前插座连接线ID);
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_Mesh) {
			return socket->f_getData(0);
		}
		else if (socket->m_Type == E_值类型::e_Type_Mesh_1D) {
			auto& data = *DEF_网格插座_1D数据(socket, 0);
			if (data.count) {
				m_Value = data.ptr_userData[0];
			}
			else {
				m_Value = nullptr;
			}
		}
		else if (socket->m_Type == E_值类型::e_Type_Object) {
			auto* data = DEF_物体插座数据(socket, 0);
			
			m_Value = f_ob_fromMesh(data);
		}
		else if (socket->m_Type == E_值类型::e_Type_Object_1D) {
			auto* data = DEF_物体插座_1D数据(socket, 0);
			if (data->count) {
				m_Value = f_ob_fromMesh(data->ptr_userData[0]);
			}
			else {
				m_Value = nullptr;
			}
		}
		else if (socket->m_Type == E_值类型::e_Type_Object_Array1D) {
			auto& data = *DEF_物体插座_Array1D数据(socket, 0);
			if (data.size()) {
				m_Value = f_ob_fromMesh(data[0]);
			}
			else {
				m_Value = nullptr;
			}
		}
		else if (socket->m_Type == E_值类型::e_插座Type_引用数据) {
			auto& inData = *DEF_引用插座数据(socket, 当前插座连接线ID);
			if (inData.m_Type == E_值类型::e_Type_Mesh) {
				return inData.m_Data;
			}
			else if (inData.m_Type == E_值类型::e_Type_Mesh_1D) {
				const auto& data = *DEF_引用转MESH_1D(inData);
				if (data.size()) {
					m_Value = data[0];
				}
			}
			else if (inData.m_Type == E_值类型::e_Type_Object) {
				m_Value = f_ob_fromMesh((S_物体*)inData.m_Data);
			}
		}
	}
	else if(f_isLink() == false){
		m_Value = {};
	}
	return m_Value;
}

void C_网格插座::f_setData(void* data, uint8 线程ID) {
	if (data) {
		m_Value = ((S_Mesh*)data);
	}
}

std::string C_网格插座::f_构建变量代码(int32 loc) {
	std::string code;
	C_插座基类* socket = f_getLinkOutSocket(loc);

	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_Mesh) {
			m_Code = socket->f_getCode(loc);
			return "";
		}

		m_Code = m_pNode->f_getName() + f_getName() + "_to_Mesh";

		code = DEF_S(S_Mesh*)" " + m_Code + ";\n";
		switch (socket->m_Type) {
			//case E_值类型::e_Type_Object: {
			//	code += m_Code + "->ptr_userData[0] = " + socket->f_getCode() + ";\n";
			//	break;
			//}
			//case E_值类型::e_Type_Object: {
			//	code += m_Code + "->ptr_userData[0] = " + socket->f_getCode() + ";\n";
			//	break;
			//}
		}
		//f_getNode()->m_ReleaseCode += DEF_S(f_core_array_resize);
	}
	else {
		C_插座基类::f_构建变量代码(loc);
		m_Code = "&" + m_Code;
	}
	return code;
}

bool C_网格插座::f_接入插座是否匹配(E_值类型 type) {
	switch (m_Type) {
		case E_值类型::e_Type_Object:
		case E_值类型::e_Type_Object_1D:
		case E_值类型::e_Type_多边形:
		case E_值类型::e_Type_多边形_1D:
		case E_值类型::e_Type_Mesh_1D:
		case E_值类型::e_Type_Mesh:
			return true;
	}
	return false;
}

void C_网格插座::f_释放数据() {
	m_Value = {};
	//f_释放独立网格插座数量(&m_Value);
}

/*PyObject* C_网格插座::f_getPyData() {
	const S_网格插座数据* data = (S_网格插座数据*)f_getData();
	return nullptr;
}*/












/*C_集合插座::C_集合插座(string name)
	:C_插座基类(name, E_插座类型::e_插座Type_集合)
{
}

C_集合插座::~C_集合插座()
{
}

void * C_集合插座::f_getData() {
	C_插座基类* socket = f_getLinkOutSocket();
	if (socket) {
		if (socket->m_Type == E_插座类型::e_插座Type_集合) {
			return dynamic_cast<C_集合插座*>(socket)->f_getData();
		}
	}
	return m_Object;
}

void C_集合插座::f_setData(void * data, int64 ID)
{
	C_插座基类::f_setData(data);

	m_Object = (PyObject*)data;
}*/



C_多边形插座::C_多边形插座(std::wstring name) :C_插座基类(name, E_值类型::e_Type_多边形) {
	m_默认值 = f_surface_创建多边形();
	m_转换值 = nullptr;
	m_Value = m_默认值;
}

C_多边形插座::~C_多边形插座() {
	f_surface_销毁多边形(m_默认值);
}

void* C_多边形插座::f_getData(uint8 当前插座连接线ID) {
	C_插座基类* socket = f_getLinkOutSocket(当前插座连接线ID);
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_多边形) {
			return socket->f_getData(0);
		}
		else if (socket->m_Type == E_值类型::e_Type_多边形_1D) {
			auto& data = *DEF_多边形_1D插座数据(socket, 0);
			if (data.count) {
				m_转换值 = data.ptr_userData[0];
			}
			else {
				m_转换值 = nullptr;
			}
		}
		else if (socket->m_Type == E_值类型::e_Type_Object_1D) {
			auto& data = *DEF_物体插座_1D数据(socket, 0);
			if (data.count && data.ptr_userData[0]->m_Type == E_物体类型::t_多边形) {
				m_转换值 = (S_多边形*)(data.ptr_userData[0]->m_UserData);
			}
			else {
				m_转换值 = nullptr;
			}
		}
		else if (socket->m_Type == E_值类型::e_Type_Object_Array1D) {
			auto& data = *DEF_物体插座_Array1D数据(socket, 0);
			if (data.size() && data[0]->m_Type == E_物体类型::t_多边形) {
				m_转换值 = (S_多边形*)(data[0]->m_UserData);
			}
			else {
				m_转换值 = nullptr;
			}
		}
		else if (socket->m_Type == E_值类型::e_Type_Object) {
			auto& data = *DEF_物体插座数据(socket, 0);
			m_转换值 = (S_多边形*)(data.m_UserData);
		}
		else if (socket->m_Type == E_值类型::e_插座Type_引用数据) {
			auto& inData = *DEF_引用插座数据(socket, 当前插座连接线ID);
			if (inData.m_Type == E_值类型::e_Type_多边形) {
				return inData.m_Data;
			}
		}

		m_Value = m_转换值;
	}
	else if (!m_映射指针) {
		m_Value = m_默认值;
	}
	return m_Value;
}

void C_多边形插座::f_setData(void* data, uint8 线程ID) {
	if (data) {
		m_Value = (S_多边形*)data;
		m_映射指针 = true;
	}
	else {
		m_Value = m_默认值;
		m_映射指针 = false;
	}
}

std::string C_多边形插座::f_构建变量代码(int32 loc) {
	std::string code;
	C_插座基类* socket = f_getLinkOutSocket(loc);

	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_多边形) {
			m_Code = socket->f_getCode(loc);
			return "";
		}

		m_Code = m_pNode->f_getName() + f_getName() + "_to_Poly";

		//code = DEF_S(f_core_array_resize)"((S_Array*)" + m_Code + ", 1);\n";
		code = DEF_S(S_多边形*)" " + m_Code + ";\n";
		switch (socket->m_Type) {
			case E_值类型::e_Type_Object: {
				//code += m_Code + "->ptr_userData[0] = " + socket->f_getCode(loc) + ";\n";
				code += m_Code + " = " + socket->f_getCode(loc) + "->ptr_userData[0];\n";
				break;
			}
			case E_值类型::e_Type_多边形_1D: {
				code += m_Code + " = " + socket->f_getCode(loc) + "->ptr_userData[0];\n";
				break;
			}
		}
		//f_getNode()->m_ReleaseCode += DEF_S(f_core_array_resize);
	}
	else {
		C_插座基类::f_构建变量代码(loc);
		m_Code = "&" + m_Code;
	}
	return code;
}

bool C_多边形插座::f_接入插座是否匹配(E_值类型 type) {
	switch (m_Type) {
		case E_值类型::e_Type_Object:
		case E_值类型::e_Type_Object_1D:
		case E_值类型::e_Type_多边形:
		case E_值类型::e_Type_多边形_1D:
			return true;
	}
	return false;
}

void C_多边形插座::f_释放数据() {
}





C_多边形插座_1D::C_多边形插座_1D(std::wstring name) :C_插座基类(name, E_值类型::e_Type_多边形_1D) {
	m_默认值 = (S_多边形Array*)f_core_array_new(0, sizeof(S_多边形*));
	m_转换值 = (S_多边形Array*)f_core_array_new(0, sizeof(S_多边形*));

	m_Value = m_默认值;
}

C_多边形插座_1D::~C_多边形插座_1D() {
	f_core_array_free((S_Array*)m_默认值);
	f_core_array_free((S_Array*)m_转换值);
}

void* C_多边形插座_1D::f_getData(uint8 当前插座连接线ID) {
	C_插座基类* socket = f_getLinkOutSocket(当前插座连接线ID);
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_多边形_1D) {
			return socket->f_getData(0);
		}
		else if (socket->m_Type == E_值类型::e_Type_多边形_1D) {
			return socket->f_getData(0);
		}
		else if (socket->m_Type == E_值类型::e_Type_Object) {
			auto* ob = DEF_物体插座数据(socket, 0);
			if (ob->m_Type == E_物体类型::t_多边形) {
				f_core_array_resize((S_Array*)m_转换值, 1);
				m_转换值->ptr_userData[0] = (S_多边形*)ob->m_UserData;
			}
			else {
				f_core_array_resize((S_Array*)m_转换值, 0);
			}
		}
		else if (socket->m_Type == E_值类型::e_Type_Object_1D) {
			auto* ob = DEF_物体插座_1D数据(socket, 0);
			if (ob->count && ob->ptr_userData[0]->m_Type == E_物体类型::t_多边形) {
				f_core_array_resize((S_Array*)m_转换值, 1);
				m_转换值->ptr_userData[0] =(S_多边形*)ob->ptr_userData[0]->m_UserData;
			}
			else {
				f_core_array_resize((S_Array*)m_转换值, 0);
			}
		}
		else if (socket->m_Type == E_值类型::e_Type_多边形) {
			auto* data = DEF_多边形插座数据(socket, 0);
			f_core_array_resize((S_Array*)m_转换值, 1);
			m_转换值->ptr_userData[0] = data;
		}

		m_Value = m_转换值;
	}
	else if (!m_映射指针) {
		m_Value = m_默认值;
	}

	return m_Value;
}

void C_多边形插座_1D::f_setData(void* data, uint8 线程ID) {
	if (data) {
		m_Value = (S_多边形Array*)data;
		m_映射指针 = true;
	}
	else {
		m_Value = m_默认值;
		m_映射指针 = false;
	}
}

std::string C_多边形插座_1D::f_构建变量代码(int32 loc) {
	std::string code;
	C_插座基类* socket = f_getLinkOutSocket(loc);

	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_多边形_1D) {
			m_Code = socket->f_getCode(loc);
			return "";
		}

		m_Code = m_pNode->f_getName() + f_getName() + "_to_Poly";

		code = DEF_S(S_多边形Array*)" " + m_Code + " = " + f_代码构建_创建数组(E_值类型::e_Type_多边形_1D, 1);
		switch (socket->m_Type) {
			case E_值类型::e_Type_Object: {
				//code += m_Code + "->ptr_userData[0] = " + socket->f_getCode(loc) + ";\n";
				break;
			}
			case E_值类型::e_Type_多边形: {
				code += m_Code + "->ptr_userData[0] = " + socket->f_getCode(loc) + ";\n";
				break;
			}
		}
		
		m_pNode->m_ReleaseCode += f_代码构建_销毁数组(m_Code);
	}
	else {
		C_插座基类::f_构建变量代码(loc);
		m_Code = "&" + m_Code;
	}
	return code;
}
bool C_多边形插座_1D::f_接入插座是否匹配(E_值类型 type) {
	switch (m_Type) {
		case E_值类型::e_Type_Object:
		case E_值类型::e_Type_Object_1D:
		case E_值类型::e_Type_多边形:
		case E_值类型::e_Type_多边形_1D:
			return true;
	}
	return false;
}






C_多边形面插座_1D::C_多边形面插座_1D(std::wstring name) :C_插座基类(name, E_值类型::e_Type_多边形面1D) {

}

C_多边形面插座_1D::~C_多边形面插座_1D(){
}

void* C_多边形面插座_1D::f_getData(uint8 当前插座连接线ID) {
	return nullptr;
}

void C_多边形面插座_1D::f_setData(void* data, uint8 线程ID) {
}





C_元素选择插座::C_元素选择插座(std::wstring name) :C_插座基类(name, E_值类型::e_Type_元素选择) {
	m_默认值 = f_array_元素选择_alloc();
	m_Value = m_默认值;
}

C_元素选择插座::~C_元素选择插座() {
}

void* C_元素选择插座::f_getData(uint8 当前插座连接线ID) {
	C_插座基类* socket = f_getLinkOutSocket(当前插座连接线ID);
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_元素选择) {
			return socket->f_getData(0);
		}
		else if (socket->m_Type == E_值类型::e_Type_多边形) {
			m_Value;
		}
	}
	else if (f_isLink() == false) {
		m_Value = m_默认值;
	}
	return m_Value;
}

void C_元素选择插座::f_setData(void* data, uint8 当前插座连接线ID) {
	m_Value = (S_ElementSelect*)data;
}

bool C_元素选择插座::f_接入插座是否匹配(E_值类型 type) {
	switch (type) {
	case E_值类型::e_Type_元素选择:
		return true;
	}
	std::cout<<"接入插座类型不支持"<<std::endl;
	return false;
}








C_元素数组选择插座::C_元素数组选择插座(std::wstring name) :C_插座基类(name, E_值类型::e_Type_元素选择1D) {
	m_默认值 = f_array_元素选择数组_alloc();
	m_Value = m_默认值;
}

C_元素数组选择插座::~C_元素数组选择插座() {
}

void* C_元素数组选择插座::f_getData(uint8 loc) {
	C_插座基类* socket = f_getLinkOutSocket(loc);
	if (socket) {
		if (socket->m_Type == E_值类型::e_Type_元素选择1D) {
			return socket->f_getData(loc);
		}
		else if (socket->m_Type == E_值类型::e_Type_多边形) {
			m_Value;
		}
	}
	else if (f_isLink() == false) {
		m_Value = m_默认值;
	}
	return m_Value;
}

void C_元素数组选择插座::f_setData(void* data, uint8 当前插座连接线ID) {
	m_Value = (S_ElementSelectArray*)data;
}

bool C_元素数组选择插座::f_接入插座是否匹配(E_值类型 type) {
	switch (type) {
	case E_值类型::e_Type_元素选择:
	case E_值类型::e_Type_元素选择1D:
		return true;
	}
	std::cout<<"接入插座类型不支持"<<std::endl;
	return false;
}








/*C_场景插座::C_场景插座(string name)
	:C_插座基类(name, E_插座类型::e_插座Type_Scene)
{
	//m_Object = 0;
}

C_场景插座::~C_场景插座()
{
}

void * C_场景插座::f_getData() {
	C_插座基类* socket = f_getLinkOutSocket();
	if (socket) {
		if (socket->m_Type == E_插座类型::e_插座Type_Scene) {
			return dynamic_cast<C_场景插座*>(socket)->f_getData();
		}
	}
	return &m_Object;

}

void C_场景插座::f_setData(void* data) {
	m_Object = f_Py字符串转string((PyObject*)data);

	//m_Object = PyTuple_New(2);
	//PyTuple_SetItem(m_Object, 0, PyTuple_GetItem(co, 0));
	//PyTuple_SetItem(m_Object, 1, PyTuple_GetItem(co, 1));
}*/



/*C_Bl网格插座::C_Bl网格插座(string name)
	:C_插座基类(name, E_插座类型::e_插座Type_BlMesh)
{
}

C_Bl网格插座::~C_Bl网格插座()
{
}

const void * C_Bl网格插座::f_getData() {
	C_插座基类* socket = f_getLinkOutSocket();
	if (socket) {
		if (socket->m_插座类型 == E_插座类型::e_插座Type_Scene) {
			return dynamic_cast<C_场景插座*>(socket)->f_getData();
		}
	}
	return &m_Object;
}

void C_Bl网格插座::f_setData(void * data)
{
}*/






/*C_平面插座::C_平面插座(string name)
	:C_插座基类(name, E_插座类型::e_插座Type_物理平面)
{
}

C_平面插座::~C_平面插座() {

}

void * C_平面插座::f_getData() {
	C_插座基类* socket = f_getLinkOutSocket();
	if (socket) {
		if (socket->m_Type == E_插座类型::e_插座Type_物理平面) {
			return dynamic_cast<C_场景插座*>(socket)->f_getData();
		}
	}
	return &m_平面属性;
}

void C_平面插座::f_setData(void * data, int64 ID) {
	m_平面属性 = *((S_平面属性*)data);
}*/









/*
C_物理体插座::C_物理体插座(string name)
	:C_插座基类(name, E_插座类型::e_插座Type_物理体)
{
}

C_物理体插座::~C_物理体插座() {
}

void * C_物理体插座::f_getData() {
	C_插座基类* socket = f_getLinkOutSocket();
	if (socket) {
		if (socket->m_Type == E_插座类型::e_插座Type_物理体) {
			return dynamic_cast<C_物理体插座*>(socket)->f_getData();
		}
	}
	return &m_Value;
}

void C_物理体插座::f_setData(void* data, int64 ID) {
	m_Value = *((S_bl物理体对象包*)data);
}
*/











C_树路径插座::C_树路径插座(std::wstring name) :C_插座基类(name, E_值类型::e_插座Type_树路径) {

}
C_树路径插座::~C_树路径插座() {

}

void* C_树路径插座::f_getData(uint8 线程ID) {
	C_插座基类* socket = f_getLinkOutSocket();
	if (socket) {
		if (socket->m_Type == E_值类型::e_插座Type_树路径) {
			return socket->f_getData(线程ID);

		}
		else if (socket->m_Type == E_值类型::e_Type_Object_Array1D) {

		}
	}

	
	return &m_Value;
}

void C_树路径插座::f_setData(void* data, uint8 线程ID) {

}

void C_树路径插座::f_释放数据() {
	m_Value.clear();
}

